﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Zebra.DataAccess
{
    public partial class User : BaseValidation
    { 
        public string Password { get { return this.Staffs[0].Password; } }

        public static User Create()
        {
            User user = new User();
            //user.Staffs = null;

            return user;
        }

        //partial void OnNameChanging(string value)
        //{
        //    IsNameValid(value);
        //}

        //partial void OnValidate(System.Data.Linq.ChangeAction action)
        //{
        //    Validate();
        //    if (!IsValid)
        //        throw new ValidationException(this.Error);
        //}

        public Boolean IsNameValid(string value)
        {
            if (string.IsNullOrEmpty(value))
            {
                Add("Address", "Name is required");
                return false;
            }
            else
            {
                Remove("Address");
                return true;
            }
        }

        public Boolean Validate()
        {
            IsNameValid(this.Name);
            return IsValid;
        }
    }

    public static class UserInfo
    {
        public static int Id { get; set; }
        public static string Name { get; set; }
        public static string Password { get; set; }
        public static int Role { get; set; }
    }
}
